package com.molichuxing.gateway.bff.dealer.services.impl;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.molichuxing.framework.exception.BizException;
import com.molichuxing.gateway.bff.dealer.convertor.Convert;
import com.molichuxing.gateway.bff.dealer.services.DealerBffService;
import com.molichuxing.gateway.utils.entity.DealerEntity;
import com.molichuxing.services.infrastructure.dto.response.DealerDto;
import com.molichuxing.services.infrastructure.service.DealerService;

@Service("dealerBffService")
public class DealerBffServiceImpl implements DealerBffService {
	private static final Logger logger = LoggerFactory.getLogger(DealerBffServiceImpl.class);

	@Resource
	private DealerService dealerService;

	/**
	 * 获取经销商信息
	 * 
	 * @param dealerId
	 *            经销商id
	 * @return
	 * @throws Exception
	 */
	@Override
	public DealerEntity getDealerEntity(Integer dealerId) throws Exception {
		DealerDto dealerDto = dealerService.getDealerById(dealerId);
		if (dealerDto == null) {
			throw new BizException("获取经销商信息失败，经销商不存在");
		}
		return Convert.toDealerEntity(dealerDto);
	}

}
